package com.sunshine.ribbon.controller;

import com.sunshine.ribbon.bean.Person;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author WeiHong
 * @date 2018/11/13
 */
@RestController
public class MyController {

    @GetMapping(value = "findPerson/{personId}", produces = MediaType.APPLICATION_JSON_VALUE)
    public Person findPerson(@PathVariable("personId") int personId, HttpServletRequest request){
        return new Person(personId, 30, "sunshine", request.getRequestURL().toString());
    }

    @GetMapping("/")
    public String hello(){
        return "hello";
    }
}
